package com.gitee.wsl.serialization

import kotlin.reflect.KClass
import kotlin.reflect.KProperty1


fun<T : Enum<*>> EnumAsNameSerializer(
         enumClass: KClass<T>,
         field: KProperty1<T, String>,
      ) = EnumAsNameSerializer(
            serialName = enumClass.simpleName!!,
             serialize = { field.get(it) },
          deserialize = { name -> enumClass.java.enumConstants.first { field.get(it) == name } }
       )